package com.shenhaofeng.app.loader.list.component;

import android.os.Looper;
import android.support.v7.widget.RecyclerView;

import com.shenhaofeng.app.adapter.SingleTypeMoreAdapter;
import com.shenhaofeng.app.loader.list.listener.OnMoreStatusListener;
import com.shenhaofeng.app.loader.list.listener.OnRefreshStatusListener;

import java.util.concurrent.Executor;


/**
 * 单数据类型的配置类,通过实现抽象方法,实现数据的加载绑定
 * Created by Administrator on 2016/8/28.
 */
public abstract class SingleSwipeRecyclerComponent<D> extends SwipeRecyclerComponent<D> {
    public SingleSwipeRecyclerComponent(OnRefreshStatusListener<D> statusListener, RecyclerView.Adapter adapter, OnMoreStatusListener<D> mOnMoreStatusListener) {
        super(statusListener, adapter, mOnMoreStatusListener);
    }


    public SingleSwipeRecyclerComponent(Executor mExecutor, OnRefreshStatusListener<D> statusListener, RecyclerView.Adapter adapter, OnMoreStatusListener<D> mOnMoreStatusListener) {
        super(mExecutor, statusListener, adapter, mOnMoreStatusListener);
    }


    public SingleSwipeRecyclerComponent(Looper mLooper, OnRefreshStatusListener<D> statusListener, RecyclerView.Adapter adapter, OnMoreStatusListener<D> mOnMoreStatusListener) {
        super(mLooper, statusListener, adapter, mOnMoreStatusListener);
    }


//    public SingleSwipeRecyclerComponent(SingleTypeMoreAdapter<? extends RecyclerView.ViewHolder, D> moduleAdapter, OnMoreStatusListener<D> handler) {
////        super(moduleAdapter, handler);
//    }


//    private RecyclerView recyclerView;
//
//
//
//
//
//    @Override
//    protected void onBindDataToAdapter(ModuleAdapter moduleAdapter, D data) {
//        if (checkSingleAdapter(moduleAdapter)) {
//            SingleTypeMoreAdapter singleTypeMoreAdapter = (SingleTypeMoreAdapter) moduleAdapter;
//            onBindDataToAdapter(singleTypeMoreAdapter, data);
//        }
//    }
//
//
//    @Override
//    protected void onStatusChange(Status status) {
//        RecyclerView.Adapter adapter = recyclerView.getAdapter();
//        if (adapter != null && adapter instanceof SingleTypeMoreAdapter) {
//            if (status.getStatusCode() == Status.CMD_INSTALL) {
//                ((SingleTypeMoreAdapter) adapter).installStatus();
//            }else if(status.getStatusCode()==Status.CMD_UNINSTALL){
//                ((SingleTypeMoreAdapter) adapter).uninstallStatus();
//            }
//            ((SingleTypeMoreAdapter) adapter).getStatus().put(status.getStatusCode(), status.getMessage());
//            ((SingleTypeMoreAdapter) adapter).getStatus().setCurrentStatus(status.getStatusCode());
//        }
//    }
//
//
//    /**
//     * 绑定数据到适配器
//     *
//     * @param adapter
//     * @param data
//     */
//    protected abstract void onBindDataToAdapter(SingleTypeMoreAdapter adapter, D data);
//
//
//    /**
//     * 检查是否是单item类型的Adapter
//     * @param moduleAdapter
//     * @return
//     */
//    protected boolean checkSingleAdapter(ModuleAdapter moduleAdapter) {
//        return moduleAdapter != null && moduleAdapter instanceof SingleTypeMoreAdapter;
//    }

}
